package com.sunsharing.flow.model.node;

import com.sunsharing.common.anno.Factory;
import com.sunsharing.dispatch.Dispatch;
import com.sunsharing.flow.exe.ExecutionContext;
import com.sunsharing.wsdlcall.Request;
import org.apache.log4j.Logger;

/**
 * Created with IntelliJ IDEA.
 * User: criss
 * Date: 13-5-9
 * Time: 下午9:56
 * To change this template use File | Settings | File Templates.
 */
@Factory(key="webservice")
public class WebServiceCall extends Call {
    Logger logger = Logger.getLogger(WebServiceCall.class);

    String serviceName;

    public String getServiceName() {
        return serviceName;
    }

    public void setServiceName(String serviceName) {
        this.serviceName = serviceName;
    }

    @Override
    public boolean call(ExecutionContext context) {
        context.getToken().serviceId = serviceName;
        boolean isLocal = context.getContext().isLocal();
        if(isLocal)
        {
            //如果是本地调用服务
            Request.request(context.getContext());
            return false;
        }else
        {
            //远程
            new Dispatch().run(context.getContext());
            return true;
        }
    }
}
